/* eslint-disable @typescript-eslint/explicit-member-accessibility */
/* eslint-disable @typescript-eslint/no-explicit-any */
class Foo {
  public bar(baz: string): string;
  public bar(baz: number): number;
  public bar<T extends string | number>(baz: T): T;
  public bar(baz: string | number): string | number {
    return baz;
  }

  #bar(baz: string): string;
  #bar(baz: number): number;
  #bar<T extends string | number>(baz: T): T;
  #bar(baz: string | number): string | number {
    return baz;
  }

  _bar(baz: string): string;
  _bar(baz: number): number;
  _bar<T extends string | number>(baz: T): T;
  // 逆变只能any
  _bar(baz: any): string | number {
    return this._bar(baz) + this.#bar(baz);
  }
}

console.log(new Foo().bar(42));
